package com.freesky.biz.psbc.controller;


import com.freesky.biz.psbc.domain.TPsbcMarket;
import com.freesky.biz.psbc.domain.TPsbcMarketBankCount;
import com.freesky.biz.psbc.domain.TPsbcMarketParkCount;
import com.freesky.biz.psbc.service.IPsbcMarketService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/psbc/makert/")
public class PsbcMarketController extends BaseController {

    @Autowired
    private IPsbcMarketService psbcMarketService;

    /**
     * 邮储银行列表
     */
    @PreAuthorize("@ss.hasPermi('psbc:makert:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPsbcMarket psbcMarket) {
        startPage();
        List<TPsbcMarket> list = psbcMarketService.findList(psbcMarket);
        return getDataTable(list);
    }

    @Log(title = "邮储银行", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('psbc:makert:export')")
    @GetMapping("/export")
    public AjaxResult export(TPsbcMarket psbcMarket,
                             HttpServletResponse response) {
        return psbcMarketService.exportFile(psbcMarket);
    }

    @PreAuthorize("@ss.hasPermi('psbc:makert:list')")
    @GetMapping("/bankList")
    public TableDataInfo bankList(TPsbcMarketBankCount entity) {
        startPage();
        List<TPsbcMarketBankCount> list = psbcMarketService.findBankCountList(entity);
        return getDataTable(list);
    }

    @Log(title = "邮储银行", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('psbc:makert:export')")
    @GetMapping("/exportBank")
    public AjaxResult export(TPsbcMarketBankCount entity,
                             HttpServletResponse response) {
        return psbcMarketService.exportBankCountFile(entity);
    }

    @PreAuthorize("@ss.hasPermi('psbc:makert:list')")
    @GetMapping("/bankListById")
    public TableDataInfo bankListById(TPsbcMarketBankCount entity) {
        startPage();
        List<TPsbcMarketBankCount> list = psbcMarketService.findParkCountByBankId(entity);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('psbc:makert:list')")
    @GetMapping("/parkList")
    public TableDataInfo parkList(TPsbcMarketParkCount entity) {
        startPage();
        List<TPsbcMarketParkCount> list = psbcMarketService.findParkCountList(entity);
        return getDataTable(list);
    }

    @Log(title = "邮储银行", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('psbc:makert:export')")
    @GetMapping("/exportPark")
    public AjaxResult exportPark(TPsbcMarketParkCount entity,
                             HttpServletResponse response) {
        return psbcMarketService.exportParkCountFile(entity);
    }

}
